
import { env } from '@/utils/env'
import http from './http'
import type { Order } from '@/types/Order'
import type { ResponeData } from '@/types/HttpType'
import type { PageData } from '@/types/PageData'


export const postOrder = async (data: Order):Promise<ResponeData<Order>> => {
    return await http<Order>({
        url: env.VITE_JIANCAI + '/order/add',
        method: 'post',
        data
    })
    
}

export const putOrder = async (data: Order):Promise<ResponeData<Order>> => {
    return await http<Order>({
        url: env.VITE_JIANCAI + '/order/update',
        method: 'put',
        data
    })
    

}

export const getOrderList = async (params:any):Promise<ResponeData<PageData<any>>> => {
    return await http<PageData<any>>({
        url: env.VITE_JIANCAI + '/order/list',
        method: 'get',
        params
    })
}

export const getOrderDetail = async (id:number):Promise<ResponeData<Order>> => {
    return await http<Order>({
        url: env.VITE_JIANCAI + '/order/detail/' + id,
        method: 'get',
    })
}

export const deleteOrder = async (id: number):Promise<any> => {
    let res = await http<any>({
        url: env.VITE_JIANCAI + '/order/delete/' + id,
        method: 'delete',
    })
    return res
}
